﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace ProCodes.Utilities
{
    public class TextEncryption
    {
        public static string Decrypt(string sEncryptedText)
        {
            return Encoding.UTF8.GetString(Convert.FromBase64String(sEncryptedText));
        }

        public static string Encrypt(string sPlainText)
        {
            return Convert.ToBase64String(Encoding.UTF8.GetBytes(sPlainText));
        }

        public static string QuerystringDecrypt(string sEncryptedQueryString)
        {
            return Decrypt(Encoding.ASCII.GetString(HttpServerUtility.UrlTokenDecode(sEncryptedQueryString)));
        }

        public static string QuerystringEncrypt(string sPlainQueryString)
        {
            string sEncryptedQuery = Encrypt(sPlainQueryString);
            return HttpServerUtility.UrlTokenEncode(Encoding.ASCII.GetBytes(sEncryptedQuery));
        }
    }
}
